using System;

namespace CSharpKit.Numerics.Providers.LinearAlgebra.Managed
{
    /// <summary>
    /// partial - ok
    /// </summary>
    internal partial class ManagedLinearAlgebraProvider : ILinearAlgebraProvider
    {
        public bool IsAvailable()
        {
            return true;
        }

        public void InitializeVerify()
        {
            // throw new NotImplementedException();
        }

        public void FreeResources()
        {
            // throw new NotImplementedException();
        }


        public override string ToString()
        {
            return "Managed";
        }


        /// <summary>
        /// Assumes that <paramref name="numRows"/> and <paramref name="numCols"/> have already been transposed.
        /// </summary>
        protected static void GetRow<T>(Transpose transpose, int rowindx, int numRows, int numCols, T[] matrix, T[] row)
        {
            if (transpose == Transpose.DontTranspose)
            {
                for (int i = 0; i < numCols; i++)
                {
                    row[i] = matrix[(i * numRows) + rowindx];
                }
            }
            else
            {
                Array.Copy(matrix, rowindx * numCols, row, 0, numCols);
            }
        }

        /// <summary>
        /// Assumes that <paramref name="numRows"/> and <paramref name="numCols"/> have already been transposed.
        /// </summary>
        protected static void GetColumn<T>(Transpose transpose, int colindx, int numRows, int numCols, T[] matrix, T[] column)
        {
            if (transpose == Transpose.DontTranspose)
            {
                Array.Copy(matrix, colindx * numRows, column, 0, numRows);
            }
            else
            {
                for (int i = 0; i < numRows; i++)
                {
                    column[i] = matrix[(i * numCols) + colindx];
                }
            }
        }

        //}}@@@
    }


}
